﻿using Cms.Core.Data.Configurations;
using Cms.Core.Data.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Cms.Core.Data.Mapping
{



    public abstract class EntityMappingConfiguration<T> : IEntityMappingConfiguration<T> where T : EFEntityBase
    {
        public abstract void Map(EntityTypeBuilder<T> b);


        public virtual void MapCommon(EntityTypeBuilder<T> builder)
        {
            builder.HasKey(o => o.Id);
            builder.Property(o => o.CreateTime).HasColumnType("datetime").HasDefaultValueSql("GETDATE()");
            builder.Property(o => o.CreateUserId);
            builder.Property(o => o.ModifiedUserId);
            builder.Property(o => o.ModifiedTime).HasColumnType("datetime").HasDefaultValueSql("GETDATE()");
            builder.Property(o => o.IsDelete).HasDefaultValue(false).IsRequired();
        }
        public void Map(ModelBuilder b)
        {
            Map(b.Entity<T>());
        }
    }



}
